package com.dragon.repository.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.model.Update;
import com.dragon.repository.entity.Equipment;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.dragon.common.util.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class EquipmentVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "设备名称")
    private String equipmentName;

    @ApiModelProperty(value = "设备编号")
    private String equipmentCode;

    @ApiModelProperty(value = "设备状态：0空闲1生产中")
    private Integer type;

    @ApiModelProperty(value = "图片")
    private String img;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "预计完成时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date estimateFinishTime;

    @ApiModelProperty(value = "排产id")
    private Integer schedulingId;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Equipment convert(EquipmentVO vo) {
        Equipment entity = new Equipment();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Equipment> convertList(List<EquipmentVO> list) {
        List<Equipment> resultList = new ArrayList<>();
        for (EquipmentVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
